package com.aaa.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;

import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
@Data
@TableName("emp")
public class EmpT implements UserDetails {
@TableId(value = "empid",type = IdType.AUTO)
  private Integer empid;
  private String ename;
  private String eusername;
  private String epass;
  private String sex;
    @JsonFormat(  pattern="yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
  private Date hiredate;
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd")
    private Date leavedate;
  private String tel;
  private Integer roleid;
  private Integer state;
  @TableField(exist = false)//该字段不使用
  private Collection authorities;


    @Override
    public String toString() {
        return "Emp{" +
                "empid=" + empid +
                ", ename='" + ename + '\'' +
                ", eusername='" + eusername + '\'' +
                ", epass='" + epass + '\'' +
                ", sex='" + sex + '\'' +
                ", hiredate=" + hiredate +
                ", leavedate=" + leavedate +
                ", tel='" + tel + '\'' +
                ", roleid=" + roleid +
                ", state=" + state +
                '}';
    }

    public Integer getEmpid() {
        return empid;
    }

    public void setEmpid(Integer empid) {
        this.empid = empid;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public String getEusername() {
        return eusername;
    }

    public void setEusername(String eusername) {
        this.eusername = eusername;
    }

    public String getEpass() {
        return epass;
    }

    public void setEpass(String epass) {
        this.epass = epass;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Date getHiredate() {
        return  hiredate;
    }

    public void setHiredate(Date hiredate) {
        this.hiredate = hiredate;
    }

    public Date getLeavedate() {
        return leavedate;
    }

    public void setLeavedate(Date leavedate) {
        this.leavedate = leavedate;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public Integer getRoleid() {
        return roleid;
    }

    public void setRoleid(Integer roleid) {
        this.roleid = roleid;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }


//获取权限
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
      return this.authorities;
    }
//获取密码
    @Override
    public String getPassword() {
        return this.epass;
    }
//获取密码
    @Override
    public String getUsername() {
        return this.eusername;
    }
//用户是否过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
//用户是否锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    // 凭证是否过期:密码
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public void setAuthorities(final Collection authorities) {
        this.authorities = authorities;
    }

}
